# -*- coding: UTF-8 _*_
import time
import pytest
import os
from multiprocessing import Pool

now = time.strftime("%Y-%m-%d_%H_%M_%S", time.localtime())

def runwebcase(name='', case_path=""):
    """执行CMD命令,,'-m=aboutzentao'"""
    pytest.main(['-s', '--browser=' + name,'--case_type=web', case_path, '--alluredir', './report/tmp/' + name, '--clean-alluredir','--durations=0'])
def runwebcase1(x):
    return runwebcase(x[0],x[1])

def runappcase(case_path=""):
    pytest.main(['-s',  '--case_type=app', case_path, '--alluredir', './report/tmp/app','--clean-alluredir','--durations=0'])




def getreport(name=''):
    os.system('copy environment.properties report\\tmp\\' + name + '\\environment.properties')
    os.system('allure generate ./report/tmp/' + name + '/ -o ./report/' + name + '/' + now + '/ --clean')

if __name__ == '__main__':
    brower = [('firefox', 'case/web/test_login.py'), ('chrome', 'case/web/test_login.py')]
    with Pool(len(brower)) as pool:
        pool.map(runwebcase1, brower)
        pool.close()
        pool.join()

    getreport(name='firefox')
    getreport(name='chrome')
